<template>
  <transition name="dialog">
    <div @click.self="handleClickBg"
         class="dialog"
         v-show="show">
      <slot></slot>
    </div>
  </transition>
</template>

<script>
export default {
  props: {
    show: {
      type: Boolean,
      default: false
    },

  },

  mounted() {

  },
  methods: {
    handleClickBg() {
      this.$emit('close')
    }
  }
}
</script>

<style lang="scss" >
.dialog-enter-active,
.dialog-leave-active {
  transition: opacity 0.6s;
}
.dialog-enter,
.dialog-leave-to {
  opacity: 0;
}

.dialog {
  width: 100%;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 999;
  background-color: rgba(0, 0, 0, 0.7);
}
</style>